%%
%% This is file `marginnote.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% marginnote.dtx  (with options: `package')
%% 
%% IMPORTANT NOTE:
%% 
%% This is a generated file and you are not allowed to distribute it
%% without the source ot the work.  See below about more informations
%% about the files the work consists of.
%% 
%% Copyright (c) Markus Kohm  2005-2006
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% The author of the initial version of these work was
%% Markus Kohm <komascript@gmx.info>
%%
%% This work consists of the files marginnote.dtx, marginnote.ins,
%% and REAMDE.
%%
\ProvidesPackage{marginnote}[%
  2006/02/06 v1.0a non floating margin notes for LaTeX]
\ProcessOptions\relax
\newcommand*{\newmarginnote}{\@newl@bel{mn}}
\newcommand*{\@mn@thispage}{}
\let\@mn@thispage\@empty
\newcounter{mn@abspage}
\AtBeginDocument{\setcounter{mn@abspage}{1}%
  \g@addto@macro\@outputpage{\stepcounter{mn@abspage}}}
\newcommand*{\@mn@margintest}{%
  \expandafter\ifx\csname @mn@thispage\endcsname\@empty
    \gdef\@mn@atthispage{1}%
  \else\expandafter\ifnum \@mn@thispage=\value{mn@abspage}%
      \begingroup
        \@tempcnta\@mn@atthispage\advance\@tempcnta by \@ne
        \xdef\@mn@atthispage{\the\@tempcnta}%
      \endgroup
    \else
      \gdef\@mn@atthispage{1}%
    \fi
  \fi
  \xdef\@mn@thispage{\themn@abspage}%
  \protected@write\@auxout{\let\themn@abspage\relax}{%
    \string\newmarginnote{note.\@mn@thispage.\@mn@atthispage}{\themn@abspage}%
  }%
  \if@twoside
    \@ifundefined{mn@note.\@mn@thispage.\@mn@atthispage}{%
      \PackageInfo{marginnote}{Suggest that margin
        note \@mn@thispage.\@mn@atthispage\space will be on\MessageBreak
        absolute page \themn@abspage.\MessageBreak
        This may be wrong}%
      \ifodd\value{mn@abspage}\@tempswatrue\else\@tempswafalse\fi
    }{%
      \PackageInfo{marginnote}{Margin note \@mn@thispage.\@mn@atthispage\space
        is on absolute page \@nameuse{mn@note.\@mn@thispage.\@mn@atthispage}}%
      \ifodd\@nameuse{mn@note.\@mn@thispage.\@mn@atthispage}
        \@tempswatrue
      \else
        \@tempswafalse
      \fi
    }%
  \else
    \PackageInfo{marginnote}{right page because not two side mode}%
    \@tempswatrue
  \fi
}
\newcommand*{\marginnote}{%
  \@dblarg\@mn@marginnote
}
\newcommand{\@mn@marginnote}[2][]{%
  \ifhmode
    \@bsphack
    \begingroup
    \ifdim\@savsk>\z@\else
      \def\:{\@xifnch}\expandafter\def\: { \futurelet\@let@token\@ifnch}%
    \fi
  \else
    \begingroup
  \fi
  \@ifnextchar [{\@mn@@marginnote[{#1}]{#2}}{\@mn@@marginnote[{#1}]{#2}[\z@]}%
}
\newcommand{\@mn@@marginnote}{}
\def\@mn@@marginnote[#1]#2[#3]{%
  \endgroup
  \ifhmode
    \@mn@@@marginnote[{#1}]{#2}[{#3}]%
    \@esphack
  \else
    \@mn@@@marginnote[{#1}]{#2}[{#3}]%
  \fi
}
\newcommand{\@mn@@@marginnote}{}
\def\@mn@@@marginnote[#1]#2[#3]{%
   \begingroup
     \ifmmode\strut\let\@tempa\vadjust\else
       \if@inlabel\leavevmode\fi
       \ifhmode\strut\let\@tempa\vadjust\else\let\@tempa\mn@vlap\fi
     \fi
     \@tempa{%
       \vbox to\z@{%
         \vss
         \@mn@margintest
         \if@reversemargin\if@tempswa
             \@tempswafalse
           \else
             \@tempswatrue
         \fi\fi
         \if@tempswa
           \rlap{\kern\textwidth\kern\marginparsep\kern\marginnoterightadjust
             \vbox to\z@{\kern #3
               \vbox to\z@{%
                 \hsize\marginparwidth
                 \kern-\baselineskip\kern-\parskip
                 \marginfont\raggedrightmarginnote\hspace{\z@}\strut#2\endgraf
                 \vss}%
               \vss}%
           }%
         \else
           \llap{%
             \vbox to\z@{\kern #3
               \vbox to\z@{%
                 \hsize\marginparwidth
                 \kern-\baselineskip\kern-\parskip
                 \marginfont\raggedleftmarginnote\hspace{\z@}\strut#1\endgraf
                 \vss}%
               \vss}%
             \kern\marginparsep\kern\marginnoteleftadjust
           }%
         \fi
       }%
     }%
   \endgroup
}
\newcommand*{\marginnoterightadjust}{}
\newcommand*{\marginnoteleftadjust}{}
\let\marginnoterightadjust\z@
\let\marginnoteleftadjust\z@
\newcommand{\mn@vlap}[1]{%
  \setbox\@tempboxa\vbox to \ht\strutbox{#1\vss}%
  \box\@tempboxa\vskip-\baselineskip\ifhmode\typeout{FALSCH!}\fi
}
\providecommand*{\marginfont}{}
\newcommand*{\raggedleftmarginnote}{\raggedleft}
\newcommand*{\raggedrightmarginnote}{\raggedright}
\endinput
%%
%% End of file `marginnote.sty'.
